﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Should;

namespace NGeo.Yahoo.PlaceFinder
{
    [TestClass]
    public class RequestFlagTests
    {
        [TestMethod]
        public void Yahoo_PlaceFinder_RequestFlag_ShouldHave10Members()
        {
            ((int)RequestFlag.CoordinateDataOnly).ShouldEqual(0);
            ((int)RequestFlag.NoWoeId).ShouldEqual(1);
            ((int)RequestFlag.Global).ShouldEqual(2);
            ((int)RequestFlag.Json).ShouldEqual(3);
            ((int)RequestFlag.Php).ShouldEqual(4);
            ((int)RequestFlag.Airport).ShouldEqual(5);
            ((int)RequestFlag.TelephoneAreaCode).ShouldEqual(6);
            ((int)RequestFlag.StreetDetail).ShouldEqual(7);
            ((int)RequestFlag.TimeZone).ShouldEqual(8);
            ((int)RequestFlag.BoundingBox).ShouldEqual(9);
        }

        [TestMethod]
        public void Yahoo_PlaceFinder_RequestFlag_ShouldHaveDataContractAttribute()
        {
            Attribute.IsDefined(typeof(RequestFlag), typeof(DataContractAttribute))
                .ShouldBeTrue();
        }

        [TestMethod]
        public void Yahoo_PlaceFinder_RequestFlag_ShouldHaveEnumMemberAttributes()
        {
            var enumMembers = new Dictionary<RequestFlag, string>
            {
                { RequestFlag.CoordinateDataOnly, "C" },
                { RequestFlag.NoWoeId, "E" },
                { RequestFlag.Global, "G" },
                { RequestFlag.Json, "J" },
                { RequestFlag.Php, "P" },
                { RequestFlag.Airport, "Q" },
                { RequestFlag.TelephoneAreaCode, "R" },
                { RequestFlag.StreetDetail, "S" },
                { RequestFlag.TimeZone, "T" },
                { RequestFlag.BoundingBox, "X" },
            };

            var values = Enum.GetValues(typeof(RequestFlag)) as RequestFlag[];
            values.ShouldNotBeNull();

            Debug.Assert(values != null);
            foreach (var value in values)
            {
                value.ShouldHaveEnumMemberAttribute(enumMembers[value]);
            }
        }

    }
}
